// import { dispatch } from "C:/Users/admin/AppData/Local/Microsoft/TypeScript/3.5/node_modules/rxjs/internal/observable/pairs";

/*
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-09-02 09:42:08
 * @LastEditTime: 2019-09-09 16:17:42
 * @LastEditors: Please set LastEditors
 */
let ADDITION = "ADDITION";
let SUBTRACTION = "SUBTRACTION";
let initState = {
    number:0
}
export  function compute(state = initState,action){
    console.log(state,action)
    // console.log( state || initState)
    // let state =
   switch(action.type){
       case ADDITION:
        //    console.log(initState)
           return {
               ...state,
               number:state.number+1
        }
        case SUBTRACTION:
            return {
                ...state,
               number:state.number-1
        }
        default:
            // console.log("ni")
            return initState
   } 
   
}

// 不支持异步的
export function sum(){
    console.log("ghj")
    return {
        type:ADDITION
    }
}

export function less(){
    return {
        type:SUBTRACTION
    }
}

// export function sum(){
//     return (dispatch)=>{
//         dispatch({
//             type:ADDITION
//         })
//     }
// }

// export function less(){
//     return (dispatch)=>{
//         dispatch({
//             type:SUBTRACTION
//         })
//     }
// }
// subscribe()
// dispatch({
//     type:SUBTRACTION
// }) 